﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using OisLibrary;
using Excel = Microsoft.Office.Interop.Excel;
using System.Reflection;
namespace CreatePGSQLDataScript
{
    public partial class DiffAccountInfoPG_SQL : Form
    {
        public DiffAccountInfoPG_SQL()
        {
            InitializeComponent();
        }

        private int location = 0;
        private int processedNum = 0;
        List<int> colorOldLines = new List<int>();
        List<int> colorSameLines = new List<int>();
        List<int> colorFullSameLines = new List<int>();
        List<NewOldProductRelation> listNewOldProductRelation = new List<NewOldProductRelation>();

        List<int> BoldLines = new List<int>();

        List<StoreInfo> pgStoreList ;
        List<StoreInfo> sqlStoreList;

        //開始生成數據。
        private void btnGenerate_Click(object sender, EventArgs e)
        {
            lblCurrOpt.Text = "讀數據。。。";

            location = 0;
            processedNum = 0;
            colorOldLines = new List<int>();
            BoldLines = new List<int>();
            pgStoreList = getPGTable();
            sqlStoreList = getSQLServerTable();
            

            //裝載產品對應關係表。
            LoadNewOldProductRelation();
            pgStoreList.OrderBy(m => m.StoreId);
            sqlStoreList.OrderBy(m => m.StoreId);


            saveFileDialog1.Filter = "Excel file|*.xls";

            saveFileDialog1.ShowDialog();
            string filename = saveFileDialog1.FileName;

 

            int iCount = getCount();
            int categoryCount = getCategoryCount();

            progressBar1.Maximum = iCount;
            categoryCount = categoryCount * 4 + pgStoreList.Count + sqlStoreList.Count + 1; //此數量不準。


            lbSum.Text = iCount.ToString();

            lblCurrOpt.Text="正在處理數據。。。";

            object[,] data = new object[categoryCount, 12];


            List<string[]> data2 = new List<string[]>();

            writeDataSub(data, "產品ID", "產品名稱", "狀態", "開始日期", "結束日期", "是否試用", "產品ID", "產品名稱", "狀態", "開始日期", "結束日期", "是否試用");

            var sqlStoreKeys = sqlStoreList.GroupBy(m => m.StoreId);

            foreach (var key1 in sqlStoreKeys)
            {
                writeHeader(sqlStoreList, data, key1.Key, "舊系統(sql server)", "新系統(jgoerp)");
                colorOldLines.Add(location-1);
                List<StoreCollInfo> storeColl= unionStoreInfo(sqlStoreList, pgStoreList, key1.Key);
                writeData(storeColl, data);
            }

            var pgStoreKeys = pgStoreList.GroupBy(m => m.StoreId);

            foreach (var key2 in pgStoreKeys)
            {
                writeHeader(pgStoreList, data, key2.Key,"新系統(jgoerp)");
                writeData(pgStoreList, data, key2.Key);
            }

            lbCu.Text = processedNum.ToString();
            progressBar1.Value = processedNum;
            Application.DoEvents();

            lblCurrOpt.Text = "準備生成 Excel。。。";


            //刪除多余的顏色，優先級為：colorFullSameLines ,colorSameLines,colorOldLines



            try
            {

                for (int i = colorSameLines.Count - 1; i >= 0; i--)
                {
                    for (int k = colorOldLines.Count - 1; k >= 0; k--)
                    {
                        if (colorOldLines[k] == colorSameLines[i])
                        {
                            colorOldLines.RemoveAt(k);
                        }
                    }
                }

                for (int i = colorFullSameLines.Count - 1; i >= 0; i--)
                {
                    for (int k = colorSameLines.Count - 1; k >= 0; k--)
                    {
                        if (colorSameLines[k] == colorFullSameLines[i])
                        {
                            colorSameLines.RemoveAt(k);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("刪除多余的顏色:" + ex.Message);
            }

            TableToExcel(data, colorOldLines, colorSameLines,colorFullSameLines, filename, 12);

            MessageBox.Show("保存成功！");

        }

        //輸出舊系統頭
        private void writeHeader(List<StoreInfo> storeInfoColl, object[,] data, string storeid,string displayText,string displayText2)
        {
            var storeInfoSub = storeInfoColl.Where(m => m.StoreId == storeid).ToList<StoreInfo>();
            if (storeInfoSub.Count <= 0)
                return;
            writeDataSub(data, storeInfoSub[0].StoreId, storeInfoSub[0].Name, storeInfoSub[0].MemberType,storeInfoSub[0].MStatus);

            writeDataSub(data, displayText, "", "", "", "", "", displayText2);
        }


        //輸出新系統頭
        private void writeHeader(List<StoreInfo> storeInfoColl, object[,] data, string storeid, string displayText)
        {
            var storeInfoSub = storeInfoColl.Where(m => m.StoreId == storeid).ToList<StoreInfo>();
            if (storeInfoSub.Count <= 0)
                return;
            writeDataSub(data, storeInfoSub[0].StoreId, storeInfoSub[0].Name, storeInfoSub[0].MemberType, storeInfoSub[0].MStatus);

            writeDataSub(data, "", "", "", "", "", "", displayText);
        }



        private void writeData(List<StoreCollInfo> storeColl, object[,] data)
        {
            for (int i = 0;i< storeColl.Count ; i++)
            {
                var sub = storeColl[i];

                //添加顏色。
                colorOldLines.Add(location);

                //產品相同。
                if (isSameProduct(sub.ProductId,sub.ProductName,sub.ProductId_new,sub.ProductName_new))
                {
                    colorSameLines.Add(location);
                }

                //完全匹配
                if(isFullSameLine(sub))
                {
                    colorFullSameLines.Add(location);
                }


                writeDataSub(data, sub.ProductId,
                                  sub.ProductName,
                                  sub.Status,
                                  sub.StartDate,
                                  sub.EndDate,
                                  sub.IsFree,
                                 sub.ProductId_new,
                                sub.ProductName_new,
                                sub.Status_new,
                                sub.StartDate_new,
                                sub.EndDate_new,
                                sub.IsFree_new
                                  );

            }

            location++;
        }

        private void writeData(List<StoreInfo> storeInfoColl, object[,] data, string storeid)
        {
            var storeInfoSub = storeInfoColl.Where(m => m.StoreId == storeid).ToList<StoreInfo>();
            if (storeInfoSub.Count <= 0)
                return;

            for (int i = storeInfoSub.Count - 1; i >= 0; i--)
            {
                var sub = storeInfoSub[i];

                writeDataSub(data, "", "", "", "", "", "", 
                                  sub.ProductId,
                                  sub.ProductName,
                                  sub.Status,
                                  sub.StartDate,
                                  sub.EndDate,
                                  sub.IsFree);
                storeInfoColl.Remove(sub);
                processedNum++;
                //更新處理數量。
                if (processedNum % 100 == 0)
                {

                    lbCu.Text = processedNum.ToString();
                    progressBar1.Value = processedNum;
                    Application.DoEvents();
                }

            }

            location++;
        }


        
        //輸出列。
        private void writeDataSub(object[,] data, params object[] values)
        {
            for (int i = 0; i < values.Length; i++)
            {
                data[location, i] = values[i];
            }

            location++;
        }




        //查詢新系統的數據源。
        private List<StoreInfo> getPGTable()
        {
            try
            {
                string sqlText = @"
select si.storeid as StoreId,s.shortname as Name,p.productid as ProductId, p.productname as ProductName,'' as mstatus,
case isopen when '1' then '開通' when '0' then '關閉' else '' end as Status
, si.ddate as StartDate,si.matdate as EndDate,
case si.isfree when '1' then '是' when '0' then '否' else '' end as isfree,'' as MemberType
from storesitem si
left join stores s on s.storeid=si.storeid
left join products p on p.productid=si.productid 
";

                DataAccess.PgSqlProvider db = new DataAccess.PgSqlProvider(txtPGSQL.Text.Trim());
                DataTable dt = db.GetDataTable(sqlText);
                return ConvertTableToList(dt);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return null;
            }

        }

        //查詢舊系統的數據源。
        private List<StoreInfo> getSQLServerTable()
        {

            string memberStatus = "";

            string mType = "";

            foreach (var item1 in chklistMemberStaus.CheckedItems)
            {
                memberStatus += "," + item1.ToString().Substring(0, 1);
            }
            string strWhereMember = "";
            if (memberStatus.Length > 0)
            {
                memberStatus = memberStatus.Substring(1);
                strWhereMember = " and mbrAccount.Status in (" + memberStatus + ")";
            }

            
            foreach(var item1 in chkMType.CheckedItems)
            {
                mType += "," + item1.ToString().Substring(0, 1);
            }
            string strWhereMType = "";

            if (mType.Length > 0)
            {
                mType = mType.Substring(1);
                strWhereMType = " and mbrAccount.MemberType in (" + mType + ")";
            }





            try
            {
                //where 后面的條件去除免費項目。usp_MBR_AlermYear，usp_MBR_AlermMonth
                string sqlText = @"
select mbrAccount.Name as StoreId,mbrAccount.MemberTitle as Name,AppProgram.Name as ProductId, AppProgram.Title as ProductName,
 case mbraccount.status  when 0	then '正常'  when 1	then '停權'  when 2	then '終止'  when 3	then '新入'  when 4	then '註銷'  when 5	then '暫停'  when 6	then '託售' end as mstatus,
case 
mbrAppExpiration.Status 
when 0 then '開通' when 1 then '關閉' end Status
,mbrAppExpiration.StartDate,mbrAppExpiration.EndDate,
case mbrAccount.MemberType when '3' then '是' else '否' end isfree,
case MemberType  when 1 then '正式' when 8 then '租賃' End MemberType 
from mbrAppExpiration 
left join mbrAccount on mbrAccount.ID=mbrAppExpiration.Account
left join AppProgram on mbrAppExpiration.Program =AppProgram.ID 
where  mbrAppExpiration.MaxOnLine > 0 " + strWhereMType + strWhereMember;

                DataAccess.SqlProvider db = new DataAccess.SqlProvider(txtSQLServer.Text.Trim());
                DataTable dt = db.GetDataTable(sqlText);
                return ConvertTableToList(dt);

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return null;
            }

        }


        private List<StoreCollInfo> unionStoreInfo(List<StoreInfo> _storeOldList, List<StoreInfo> _storeNewList, string storeId)
        {
            List<StoreInfo> storeOldList = _storeOldList.Where(m=>m.StoreId==storeId).ToList<StoreInfo>();
            List<StoreInfo> storeNewList = _storeNewList.Where(m => m.StoreId == storeId).ToList<StoreInfo>();


            List<StoreCollInfo> storeColl = new List<StoreCollInfo>();
            foreach (StoreInfo storeOld in storeOldList)
            {
                StoreCollInfo UnionInfo= new StoreCollInfo
                {
                    ProductId = storeOld.ProductId,
                    ProductName = storeOld.ProductName,
                    Status = storeOld.Status,
                    StartDate = storeOld.StartDate,
                    EndDate = storeOld.EndDate,
                    IsFree = storeOld.IsFree
                };
                processedNum++;

                for (int i = storeNewList.Count - 1; i >= 0; i--)
                {
                    if (isSameProduct(storeOld.ProductId, storeOld.ProductName, storeNewList[i].ProductId, storeNewList[i].ProductName))
                    {
                        UnionInfo.ProductId_new = storeNewList[i].ProductId;
                        UnionInfo.ProductName_new = storeNewList[i].ProductName;
                        UnionInfo.Status_new = storeNewList[i].Status;
                        UnionInfo.StartDate_new = storeNewList[i].StartDate;
                        UnionInfo.EndDate_new = storeNewList[i].EndDate;
                        UnionInfo.IsFree_new = storeNewList[i].IsFree;
                        _storeNewList.Remove(storeNewList[i]);
                        storeNewList.RemoveAt(i);

                        processedNum++;

                        break;
                    }
                }
                storeColl.Add(UnionInfo);
            }
            storeColl.OrderByDescending(m => m.ProductId_new);


            for (int i = storeNewList.Count-1; i >= 0; i--)
            {
                StoreCollInfo UnionInfo = getLastStore(storeColl);

                UnionInfo.ProductId_new = storeNewList[i].ProductId;
                UnionInfo.ProductName_new = storeNewList[i].ProductName;
                UnionInfo.Status_new = storeNewList[i].Status;
                UnionInfo.StartDate_new = storeNewList[i].StartDate;
                UnionInfo.EndDate_new = storeNewList[i].EndDate;
                UnionInfo.IsFree_new = storeNewList[i].IsFree;
                _storeNewList.Remove(storeNewList[i]);
                storeNewList.RemoveAt(i);

                processedNum++;
            }


            return storeColl;


        }


        private void writeStoreColl(List<StoreCollInfo> storeColl, object[,] data)
        {
             
        }



        //判斷新舊是否為同一產品。
        private bool isSameProduct(string oldProductId, string oldProductName, string newProductId, string newProductName)
        {

            if (listNewOldProductRelation.Where(m => m.ProductId == oldProductId && m.ProductId_new == newProductId).ToList().Count > 0)
                {
                    return true;
                }

                if (oldProductName == newProductName)
                {
                    return true;
                }
                    


                
            return false;
        }


        private bool isFullSameLine(StoreCollInfo sub)
        {
            if (isSameProduct(sub.ProductId, sub.ProductName, sub.ProductId_new, sub.ProductName_new))
            {
                if (sub.StartDate.Equals(sub.StartDate_new) &&
                    sub.EndDate.Equals(sub.EndDate_new) &&
                    sub.Status.Equals(sub.Status_new))
                {
                    return true;
                }
            }
            return false;
        }



        private StoreCollInfo getLastStore(List<StoreCollInfo> storeColl)
        {
            for (int i = 0; i < storeColl.Count; i++)
            {
                if (string.IsNullOrEmpty(storeColl[i].ProductId_new))
                {
                    return storeColl[i];
                }
            }
            StoreCollInfo newStore = new StoreCollInfo();
            storeColl.Add(newStore);
            return newStore;
        }






        private void LoadNewOldProductRelation()
        {
            string sqlText = @"select othername,othername2 from apcodeb where otherid= 'pdtrel'";

            DataAccess.PgSqlProvider db = new DataAccess.PgSqlProvider(txtPGSQL.Text.Trim());
            DataTable dt = db.GetDataTable(sqlText);

            foreach (DataRow dr in dt.Rows)
            {
                listNewOldProductRelation.Add(new NewOldProductRelation { ProductId = dr["othername"].ToString(), ProductId_new = dr["othername2"].ToString() });
            }

        }



















        //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        //下面是不重要或寫死的方法;


        //資料總數，用于顯示進度條。
        private int getCount()
        {
            string sql = "select count(1) from storesitem";
            DataAccess.PgSqlProvider db = new DataAccess.PgSqlProvider(txtPGSQL.Text.Trim());
            int iCount = Convert.ToInt32(db.GetDataTable(sql).Rows[0][0]);

            sql = "select count(1) from  mbrAppExpiration";
            DataAccess.SqlProvider db2 = new DataAccess.SqlProvider(txtSQLServer.Text.Trim());

            iCount += Convert.ToInt32(db2.GetDataTable(sql).Rows[0][0]);

            return iCount;

        }

        //得到店家數量。在定義 excel 陣列時要用到。
        private int getCategoryCount()
        {
            string sql = "select count(distinct storeid) from storesitem";
            DataAccess.PgSqlProvider db = new DataAccess.PgSqlProvider(txtPGSQL.Text.Trim());
            int iCount = Convert.ToInt32(db.GetDataTable(sql).Rows[0][0]);

            sql = "select count(distinct account) from  mbrAppExpiration";
            DataAccess.SqlProvider db2 = new DataAccess.SqlProvider(txtSQLServer.Text.Trim());

            iCount += Convert.ToInt32(db2.GetDataTable(sql).Rows[0][0]);

            return iCount;

        }

        //轉換dataTable 為　list
        private List<StoreInfo> ConvertTableToList(DataTable dt)
        {
            List<StoreInfo> list = new List<StoreInfo>();
            foreach (DataRow dr in dt.Rows)
            {
                list.Add(new StoreInfo
                {
                    StoreId = dr["StoreId"].ToString(),
                    Name = dr["Name"].ToString(),
                    ProductId = dr["ProductId"].ToString(),
                    ProductName = dr["ProductName"].ToString(),
                    Status = dr["Status"].ToString(),
                    StartDate = ConvertDateToString(dr["StartDate"]),
                   EndDate = ConvertDateToString(dr["EndDate"]),
                    IsFree=dr["isfree"].ToString(),
                    MemberType =dr["MemberType"].ToString(),
                    MStatus =dr["mstatus"].ToString()
                });
            }
            return list;
        }

        //轉換日期格式為標準。
        private string ConvertDateToString(object obj)
        {
            DateTime date1;
            if (DateTime.TryParse(obj.ToString(), out date1))
            {
                return date1.ToString("yyyy-MM-dd");
            }
            return "";
        }


        //輸出EXCEL
        public void TableToExcel(object[,] dataArray, List<int> colorLines, List<int> colorSameLines,List<int> colorFullSameLines, string ExcelName, int width)
        {

            int ArrayRow = dataArray.Length / width;

            object miss = Missing.Value;
            Excel.Application excelApp = new Excel.Application();                                           //开打Excel
            excelApp.Workbooks.Add(miss);

            try
            {
                Excel.Worksheet workSheet = (Excel.Worksheet)excelApp.Worksheets[1];                        //创建工作表单
                excelApp.DisplayAlerts = false;

                workSheet.Cells.Select();                                                                   //全表自动列宽
                workSheet.Cells.Columns.AutoFit();

                Excel.Range myrange = workSheet.get_Range(workSheet.Cells[1, 1], workSheet.Cells[dataArray.Length / width, width]);      //取数组所在位置
                myrange.NumberFormat = "@";                                                                                  //设置文本格式
                Excel.Workbook workBook = excelApp.Workbooks[1];
                workSheet.get_Range(workSheet.Cells[1, 1], workSheet.Cells[dataArray.Length / width, width]).Value2 = dataArray;//把数组添加到工作表单上

                int iCount = colorLines.Count + colorSameLines.Count + colorFullSameLines.Count + ArrayRow;

                progressBar1.Value = 0;
                progressBar1.Maximum = iCount;
                lbSum.Text = iCount.ToString();

                lblCurrOpt.Text = "正在設置顏色。。。";

                int iindex = 0;

                try
                {


                    //顏色
                    foreach (int i in colorLines)
                    {
                        //workSheet.get_Range(workSheet.Cells[i + 1, 1], workSheet.Cells[i + 1, 5]).Font.Color = System.Drawing.Color.FromArgb(Color.SkyBlue.B,Color.SkyBlue.G,Color.SkyBlue.R).ToArgb(); ;// "#783114";
                        workSheet.get_Range(workSheet.Cells[i + 1, 1], workSheet.Cells[i + 1, 6]).Font.Color = System.Drawing.Color.OrangeRed.ToArgb();

                        if (i % 100 == 0)
                        {
                            progressBar1.Value = iindex;
                            lbCu.Text = iindex.ToString();
                            Application.DoEvents();
                        }
                        iindex++;
                    }

                    //顏色
                    foreach (int i in colorSameLines)
                    {
                        workSheet.get_Range(workSheet.Cells[i + 1, 1], workSheet.Cells[i + 1, 12]).Font.Color = System.Drawing.Color.Blue.ToArgb();

                        if (i % 100 == 0)
                        {
                            progressBar1.Value = iindex;
                            lbCu.Text = iindex.ToString();
                            Application.DoEvents();
                        }
                        iindex++;
                    }

                    //顏色
                    foreach (int i in colorFullSameLines)
                    {
                        workSheet.get_Range(workSheet.Cells[i + 1, 1], workSheet.Cells[i + 1, 12]).Font.Color = System.Drawing.Color.Green.ToArgb();

                        if (i % 100 == 0)
                        {
                            progressBar1.Value = iindex;
                            lbCu.Text = iindex.ToString();
                            Application.DoEvents();
                        }
                        iindex++;
                    }


                }
                catch (Exception ex)
                {
                    MessageBox.Show("正在設置顏色:" + ex.Message);
                }
                //設置開通和關閉的顏色。



                try
                {
                    for (int i = 0; i < ArrayRow; i++)
                    {
                        if (dataArray[i, 2] != null && dataArray[i, 2].ToString() == "開通")
                        {
                            workSheet.get_Range(workSheet.Cells[i + 1, 3], workSheet.Cells[i + 1, 3]).Font.Color = System.Drawing.Color.Teal.ToArgb();
                        }
                        if (dataArray[i, 8] != null && dataArray[i, 8].ToString() == "開通")
                        {
                            workSheet.get_Range(workSheet.Cells[i + 1, 9], workSheet.Cells[i + 1, 9]).Font.Color = System.Drawing.Color.Teal.ToArgb();
                        }


                        if (dataArray[i, 2] != null && dataArray[i, 2].ToString() == "關閉")
                        {
                            workSheet.get_Range(workSheet.Cells[i + 1, 3], workSheet.Cells[i + 1, 3]).Font.Color = System.Drawing.Color.DarkMagenta.ToArgb();
                        }
                        if (dataArray[i, 8] != null && dataArray[i, 8].ToString() == "關閉")
                        {
                            workSheet.get_Range(workSheet.Cells[i + 1, 9], workSheet.Cells[i + 1, 9]).Font.Color = System.Drawing.Color.DarkMagenta.ToArgb();
                        }

                        if (i % 100 == 0)
                        {
                            progressBar1.Value = iindex;
                            lbCu.Text = iindex.ToString();
                            Application.DoEvents();
                        }
                        iindex++;

                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("設置開通和關閉的顏色:" + ex.Message);
                }


                //顏色測試。

                //workSheet.get_Range(workSheet.Cells[1, 1], workSheet.Cells[1, 1]).Font.Color = System.Drawing.Color.OldLace.ToArgb();
                //workSheet.get_Range(workSheet.Cells[2, 1], workSheet.Cells[2, 1]).Font.Color = System.Drawing.Color.Teal.ToArgb();
                //workSheet.get_Range(workSheet.Cells[3, 1], workSheet.Cells[3, 1]).Font.Color = System.Drawing.Color.Thistle.ToArgb();
                //workSheet.get_Range(workSheet.Cells[4, 1], workSheet.Cells[4, 1]).Font.Color = System.Drawing.Color.Violet.ToArgb();
                //workSheet.get_Range(workSheet.Cells[5, 1], workSheet.Cells[5, 1]).Font.Color = System.Drawing.Color.Chocolate.ToArgb();
                //workSheet.get_Range(workSheet.Cells[6, 1], workSheet.Cells[6, 1]).Font.Color = System.Drawing.Color.AliceBlue.ToArgb();
                //workSheet.get_Range(workSheet.Cells[7, 1], workSheet.Cells[7, 1]).Font.Color = System.Drawing.Color.Cornsilk.ToArgb();
                //workSheet.get_Range(workSheet.Cells[8, 1], workSheet.Cells[8, 1]).Font.Color = System.Drawing.Color.DarkMagenta.ToArgb();
                //workSheet.get_Range(workSheet.Cells[9, 1], workSheet.Cells[9, 1]).Font.Color = System.Drawing.Color.DarkTurquoise.ToArgb();
                //workSheet.get_Range(workSheet.Cells[10, 1], workSheet.Cells[10, 1]).Font.Color = System.Drawing.Color.FloralWhite.ToArgb();






                progressBar1.Value = iindex;
                lbCu.Text = iindex.ToString();
                Application.DoEvents();

                lblCurrOpt.Text = "寫入Excel。。。";
                

                ////加粗
                //foreach (int i in BlodLines)
                //{
                //    workSheet.get_Range(workSheet.Cells[i + 1, 1], workSheet.Cells[i + 1, 6]).Font.Bold = "true";
                //}

                workBook.SaveAs(ExcelName, miss, miss, miss, miss, miss, Excel.XlSaveAsAccessMode.xlExclusive, miss, miss, miss, miss, miss);     //保存文件
                workBook.Close(false, miss, miss);
                workBook = null;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                excelApp.Quit();
                excelApp = null;
                GC.Collect();
                //KillExcelProcess();//结束excel进程       
            }
        }

        protected override void OnClosing(CancelEventArgs e)
        {
            base.OnClosing(e);
            Environment.Exit(Environment.ExitCode);
            Application.Exit();
        }

        private void DiffAccountInfoPG_SQL_Load(object sender, EventArgs e)
        {

            //object[,] dataa=new object[10,3];

            //dataa[0, 0] = "abc";









            chklistMemberStaus.Items.Add("0正常",true);
            chklistMemberStaus.Items.Add("1停權", true);
            chklistMemberStaus.Items.Add("2終止", true);
            chklistMemberStaus.Items.Add("3新入", true);
            chklistMemberStaus.Items.Add("4註銷", true);
            chklistMemberStaus.Items.Add("5暫停", true);
            chklistMemberStaus.Items.Add("6託售", true);


            chkMType.Items.Add("0總部", true);
            chkMType.Items.Add("1正式", true);
            chkMType.Items.Add("2業務", true);
            chkMType.Items.Add("3試用", true);
            chkMType.Items.Add("4測試", true);
            chkMType.Items.Add("5保留", true);
            chkMType.Items.Add("6免費", true);
            chkMType.Items.Add("7盒裝", true);
            chkMType.Items.Add("8租賃", true);

        }
    }

    public class StoreInfo
    {
        public string StoreId { set; get; }
        public string Name { set; get; }
        public string ProductId { set; get; }
        public string ProductName { set; get; }
        public string Status { set; get; }
        public string StartDate { set; get; }
        public string EndDate { set; get; }
        public string IsFree { set; get; }
        public string MemberType { set; get; }
        public string MStatus { set; get; }

    }

    public class StoreCollInfo
    {
        public string StoreId { set; get; }
        public string Name { set; get; }
        public string ProductId { set; get; }
        public string ProductName { set; get; }
        public string Status { set; get; }
        public string StartDate { set; get; }
        public string EndDate { set; get; }
        public string IsFree { set; get; }

        public string ProductId_new { set; get; }
        public string ProductName_new { set; get; }
        public string Status_new { set; get; }
        public string StartDate_new { set; get; }
        public string EndDate_new { set; get; }
        public string IsFree_new { set; get; }
    }

    public class NewOldProductRelation
    {
        public string ProductId { set; get; }
        public string ProductId_new { set; get; }
    }



}
